//
//  DocumentV2Cell.m
//  EnvironmentalProtection
//
//  Created by HCreater on 2018/11/19.
//  Copyright © 2018年 HCreater. All rights reserved.
//

#import "DocumentV2Cell.h"

@interface DocumentV2Cell ()

/// viewModle
@property (nonatomic, readwrite, strong) DocumentV2CellModel *viewModel;

/// IBOutlet
@property (weak, nonatomic) IBOutlet UILabel* titleLabel;
@property (weak, nonatomic) IBOutlet UILabel* nameLabel;
@property (weak, nonatomic) IBOutlet UILabel* addrLabel;
@property (weak, nonatomic) IBOutlet UIImageView* tagImgView;
@property (weak, nonatomic) IBOutlet UIImageView* avatarImgView;

@end

@implementation DocumentV2Cell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

#pragma mark - bind data
- (void)bindViewModel:(DocumentV2CellModel *)viewModel
{
    self.viewModel = viewModel;
    
    @weakify(self);
    self.titleLabel.text = self.viewModel.title;
    self.nameLabel.text = self.viewModel.name;
    self.addrLabel.text = self.viewModel.extra;
    
    [self.tagImgView setImage:MHImageNamed(self.viewModel.tag)];
    
    [self.avatarImgView yy_setImageWithURL:[NSURL URLWithString:self.viewModel.avatarImgurl] placeholder:MHImageNamed(@"placeholderLogo")];
    
    [[[self rac_signalForSelector:@selector(layoutSubviews)] takeUntil:[self rac_prepareForReuseSignal]] subscribeNext:^(id x)
    {
        @strongify(self);
        self.avatarImgView.layer.cornerRadius = self.avatarImgView.frame.size.height/2.0f;
        self.avatarImgView.layer.masksToBounds = YES;
    }];
}

@end
